﻿﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Security.Principal;
using System.Text.RegularExpressions;
using System.Web;

namespace Susha.Models
{
    public class UserClass : IPrincipal
    {
        private IIdentity identity;

        public UserClass()
        {
            identity = new GenericIdentity("Guest");
        }

        public UserClass(String email)
        {
            identity = new GenericIdentity(email);
        }

        public virtual IIdentity Identity
        {
            get
            {
                return identity;
            }
        }

        public virtual Int32 Id { get; set; }

        [Required(ErrorMessage = "Введите почту")]
        public virtual String Email { get; set; }
        
        [Required(ErrorMessage = "Введите пароль")]
        public virtual String Password { get; set; }
        
        public virtual String PasswordSalt { get; set; }

        public virtual String Role { get; set; }
        
        public virtual Boolean IsPersistent { get; set; }

        public virtual Boolean IsInRole(String role)
        {
            return this.Role.Equals(role);
        }
    }
}